package newtank.data;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
import newtank.data.assistant.SyncData;
import server.netty.GpcDataPackage;
import tool.GlobalUniqueGenerator;

/**
 * 坦克位置同步信号
 * @author lijiahao
 * @since 2022/3/19
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SyncDataSignal extends AbstractDataPackage {

    private static final long serialVersionUID = -2391310035615906263L;

    private SyncData syncData;

    public static final String SYNC_DATA = "SYNC_DATA";

    public SyncDataSignal(String unique, SyncData syncData) {
        this.index = GlobalUniqueGenerator.getGlobalId();
        this.status = 1;
        this.length = 0;
        this.code = 11;
        this.unique = unique;
        this.syncData = syncData;
    }

    @Override
    protected void filledData(GpcDataPackage gpcDataPackage) {
        filledDataHeader(gpcDataPackage, SYNC_DATA, JSONObject.toJSONString(syncData));
    }
}
